-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ABI checks: add support for loongarch #133249
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
2ea0b24
to
a1980c6
Compare
lsx? lasx? oh dear. |
LSX is a 128-bit vector extension, and LASX is a 256-bit vector extension. Parameters and return values for neither of these data types are passed through vector registers. 😃 |
Then why is the lint triggering? |
Here is the It looks fairly dubious to me. https://github.com/rust-lang/rust/blame/bfe809d93c67de03e3a84b80549927fd828ec5d0/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs#L43 |
This is not the correct fix, the correct fix is to fix the lint itself. |
I see it. But I'm not sure how to make it more accurate. Here's a case: #![feature(stdarch_loongarch)]
use std::arch::loongarch64::*;
pub unsafe fn simd(s: i32) -> u32 {
lsx_vpickve2gr_bu::<0>(lsx_vreplgr2vr_b(s))
} and the PassMode is
BackendRepr is
|
Is it true that the Rust frontend cannot determine whether a parameter is passed through a vector register or a general-purpose register based solely on |
My understanding is the frontend technically cannot precisely control it, no. |
LoongArch psABI[^1] specifies that LSX vector types are passed via general-purpose registers, while LASX vector types are passed indirectly through the stack. This patch addresses the following warnings: ``` warning: this function call uses a SIMD vector type that is not currently supported with the chosen ABI --> .../library/core/src/../../stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs:3695:5 | 3695 | __lsx_vreplgr2vr_b(a) | ^^^^^^^^^^^^^^^^^^^^^ function called here | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue rust-lang#116558 <rust-lang#116558> = note: `#[warn(abi_unsupported_vector_types)]` on by default ``` [^1]: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc
a1980c6
to
3faef27
Compare
Since we cannot determine the type of registers used for vectors in Rust's front-end, I have reverted the return type of Do you think this is ok? @workingjubilee |
Hmm. |
What we want is to both
If the backend does not expose some ability to handle register usage (which does imply that we should have a nonzero ability to get it wrong), then I think we will simply fuck things up in a different way from our current approaches. |
In either version of this PR that I have seen so far, it adjusts things in a way that fixes things for the C ABI in certain conditions. However, the motivation1 for the changes are that our current compiler contract with the Loongarch backend remains poorly-specified and poorly-understood.
So, before I merge any fixes, I would like to understand, relative to how the Loongarch backend handles the LLVMIR lowering,
Footnotes
|
LoongArch psABI1 specifies that LSX vector types are passed via general-purpose registers, while LASX vector types are passed indirectly through the stack.
This patch addresses the following warnings:
r? @workingjubilee
Footnotes
https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc ↩